package example;

import example.fast.FastMethod;
import example.fast.MethodFactory;

import java.lang.reflect.Method;

public class App {
    public static void main(String[] args) throws Exception {

        Bean bean = new Bean("Keyboard");

        Class<?> beanClass = bean.getClass();
        Method method = beanClass.getMethod("getName");
        Object name1 = method.invoke(bean);
        System.out.println(name1);

        FastMethod fastMethod = MethodFactory.create(Bean.class, "setName", void.class, String.class);
        fastMethod.invoke(bean, "Keyboard !");

        fastMethod = MethodFactory.create(Bean.class, "getName", String.class);
        Object name2 = fastMethod.invoke(bean);
        System.out.println(name2);

        fastMethod = MethodFactory.create(Bean.class, "getAge", int.class);
        Object age = fastMethod.invoke(bean);
        System.out.println(age);


    }
}
